package com.irdstudio.tdp.console.api.rest;

import java.util.List;

import com.irdstudio.sdk.beans.core.util.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.irdstudio.tdp.console.service.facade.IsrvInoutInfoService;
import com.irdstudio.tdp.console.service.vo.IsrvInoutInfoVO;
import com.irdstudio.sdk.beans.core.vo.ResponseData;
import com.irdstudio.sdk.ssm.web.AbstractController;

@RestController
@RequestMapping("/api")
public class IsrvInoutInfoController extends AbstractController  {
	
	@Autowired
	@Qualifier("isrvInoutInfoServiceImpl")
	private IsrvInoutInfoService isrvInoutInfoService;

	
	/**
	 * 列表数据查询
	 * @param page
	 * @param size
	 * @return
	 */
	@RequestMapping(value="/isrv/inout/infos", method=RequestMethod.POST)
	public @ResponseBody ResponseData<List<IsrvInoutInfoVO>> queryIsrvInoutInfoAll(
			IsrvInoutInfoVO vo) {		
		List<IsrvInoutInfoVO> outputVo = isrvInoutInfoService.queryAllOwner(vo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键查询详情
	 * @return
	 */
	@RequestMapping(value="/isrv/inout/info/{recordKeyid}", method=RequestMethod.GET)
	public @ResponseBody ResponseData<IsrvInoutInfoVO> queryByPk(@PathVariable("recordKeyid") String recordKeyid) {		
		IsrvInoutInfoVO inVo = new IsrvInoutInfoVO();
				inVo.setRecordKeyid(recordKeyid);
		IsrvInoutInfoVO outputVo = isrvInoutInfoService.queryByPk(inVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键删除信息
	 * @param isrvInoutInfo
	 * @return
	 */
	@RequestMapping(value="/isrv/inout/info", method=RequestMethod.DELETE)
	public @ResponseBody ResponseData<Integer> deleteByPk(@RequestBody IsrvInoutInfoVO inIsrvInoutInfoVo) {		
		int outputVo = isrvInoutInfoService.deleteByPk(inIsrvInoutInfoVo);
		return getResponseData(outputVo);
		
	}

	/**
	 * 根据appModelId删除信息
	 * @param isrvInoutInfo
	 * @return
	 */
	@RequestMapping(value="/isrv/inout/info/{appModelId}", method=RequestMethod.DELETE)
	public @ResponseBody ResponseData<Integer> deleteByAppModelId(@RequestBody IsrvInoutInfoVO inIsrvInoutInfoVo) {
		int outputVo = isrvInoutInfoService.deleteByAppModelId(inIsrvInoutInfoVo);
		return getResponseData(outputVo);

	}
	
	/**
	 * 根据主键更新信息
	 * @param inIsrvInoutInfoVo
	 * @return
	 */
	@RequestMapping(value="/isrv/inout/info", method=RequestMethod.PUT)
	public @ResponseBody ResponseData<Integer> updateByPk(@RequestBody IsrvInoutInfoVO inIsrvInoutInfoVo) {		
		int outputVo = isrvInoutInfoService.updateByPk(inIsrvInoutInfoVo);
		return getResponseData(outputVo);
		
	}

	/**
	 * 根据AppModelId更新信息
	 * @param inIsrvInoutInfoVo
	 * @return
	 */
	@RequestMapping(value="/isrv/inout/infoNew", method=RequestMethod.PUT)
	public @ResponseBody ResponseData<Integer> updateAppModelId(@RequestBody IsrvInoutInfoVO inIsrvInoutInfoVo) {
		int outputVo = isrvInoutInfoService.updateAppModelId(inIsrvInoutInfoVo);
		return getResponseData(outputVo);

	}
	
	/**
	 * 新增数据
	 * @param inIsrvInoutInfoVo
	 * @return
	 */
	@RequestMapping(value="/isrv/inout/info", method=RequestMethod.POST)
	public @ResponseBody ResponseData<Integer> insertIsrvInoutInfo(@RequestBody IsrvInoutInfoVO inIsrvInoutInfoVo) {
		String recordkeyid= UUIDUtil.getUUID();
        inIsrvInoutInfoVo.setRecordKeyid(recordkeyid);
		int outputVo = isrvInoutInfoService.insertIsrvInoutInfo(inIsrvInoutInfoVo);
		return getResponseData(outputVo);
		
	}
}
